home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; frac32.asm
- ;
- ; staff
- ;
- ; 05-02-91
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- Example 7-xy. 32-bit Fractional Multiplication
-
-
-
- .title "32-bit Fractional Multiplication"
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; This routine multiplies two Q31 signed integers resulting
- ; in a Q30 product. The operands are fetched from data
- ; memory and the result is written back to data memory.
- ; Data Storage:
- ; X1,X0 Q31 operand
- ; Y1,Y0 Q31 operand
- ; W1,W0 Q30 product
- ; Entry Conditions:
- ; DP = 6, SXM = 1
- ; OVM = 0
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- X1 .set 300h ;DP=6
- X0 .set 301h ;DP=6
- Y1 .set 302h ;DP=6
- Y0 .set 303h ;DP=6
- W1 .set 304h ;DP=6
- W0 .set 305h ;DP=6
-
-
- .text
-
- BIT X0,0 ; TC = X0 bit#15
- LT X0 ; TREG0 = X0
- MPY Y1 ; P = X0*Y0
- LTP X1 ; Acc = X0*Y0
- MPY Y0 ; P = X1*Y0
- MPYA Y1 ; Acc = X0*Y0 + X1*Y0
- BSAR 16 ; Throw away low 16 bits
- XC 1,TC ; If MSB of X0 is 1
- ADD Y1 ; then add Y1
- BIT Y0,0 ; TC = Y0 bit#15
- APAC ; Acc = Acc + X1*Y1
- XC 1,TC ; If MSB of Y0 is 1
- ADD X1 ; then add X1
- SACL W0 ; Save lower product
- SACH W1 ; Save upper product
-